$.jQTouch();

$(document).ready(function(e) {
    var height = $(this).height();
    var width = $(this).width();

    $('#jqt').bind('pageAnimationEnd', function(event, info) {
        // Setup width and height of image
        if (info.direction == 'in') {
            imageSize($('.image img'));
        }
    });

    $('body').bind('orientationchange', function(event, info) {
        height = $(document).height();
        width = $(document).width();
        imageSize($('image img'));
    });

    function imageSize(images) {
        images.each(function() {
            var image = $(this);
            var ratio = 0;
            if (image.width() > image.height()) {
                ratio = image.width() / image.height();
                image.width(width);
                image.height(width / ratio);
            } else {
                ratio = image.height() / image.width();
                image.width(height / ratio);
                image.height(height);
            }
        });
    }

});

